/**
 * @param {string} s
 * @return {number}
 */
// 疯狂超时，优化不明白
 var minFlips = function(s) {
    let len = s.length
    let t1 = '', t2 = ''
    for(let i = 0; i<len; i++){
        if(i % 2 === 0){
            t1 += '1'
            t2 += '0'
        }else{
            t1 += '0'
            t2 += '1'
        }
    }
    let ans = Number.MAX_SAFE_INTEGER
    for(let k = 0; k<len; k++){
        let tail = s[0]
        s = s.slice(1) + tail
        let x = 0, y = 0
        for(let i = 0; i<len; i++){
            if(s[i] !== t1[i]){
                x++
            }
            if(s[i] !== t2[i]){
                y++
            }
        }
        ans = Math.min(ans,x,y)
    }
    return ans
};